<template>
  <div>
    <div class="table-content">
      <el-table :data="tableData.list" border style="width: 100%" @sort-change="tableSortChange" v-loading="loading" max-height="550">
        <el-table-column
          v-for="item of tableData.header"
          :key="item.engColName"
          :prop="item.engColName"
          :label="item.chnColName"
          :sortable="item.sort == 1 ? 'custom' : false"
          :width="180"
          align="center"
        >
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="100" align="center">
          <template slot-scope="scope">
            <el-button @click.native.prevent="operationRow(scope.row.id)" type="text" style="width: 100%" size="small">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <pagination
      :current-page="currentPage"
      :page-size="pageSize"
      :total="tableData.totalDataCount"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    >
    </pagination>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination.vue'

export default {
  props: ["tableData","loading","pageIndex"],
  components: {
    Pagination
  },
  data() {
    return {
      sort: '',
      currentPage: 1,
      pageSize: 10, //每页展示条数
    }
  },
  methods: {
    // 排序
    tableSortChange(val) {
      this.sort = val.order == 'ascending' ? val.prop + ' ' + 'asc' : val.order == 'descending' ? val.prop + ' ' + 'desc' : ''
      const ch = {
        sort: this.sort,
        currentPage: this.currentPage,
        pageSize: this.pageSize,
      }
      this.$emit('pageChange', ch)
    },
    // 页码-每页**条
    handleSizeChange(val) {
      this.pageSize = val
      this.currentPage = 1
      const ch = {
        sort: this.sort,
        currentPage: this.currentPage,
        pageSize: this.pageSize,
      }
      this.$emit('pageChange', ch)
    },
    // 页码-当前**页
    handleCurrentChange(val) {
      this.currentPage = val
      const ch = {
        sort: this.sort,
        currentPage: this.currentPage,
        pageSize: this.pageSize,
      }
      this.$emit('pageChange', ch)
    },
    // 查看
    operationRow(rowId) {
      console.log('lllllllllllll', rowId)
      console.log("当前页面的索引是。。。",this.pageIndex);
      this.$emit('current', this.pageIndex);
    },
  }
}
</script>

<style>

</style>